#ifndef RECORD_H
#define RECORD_H

#include <QObject>
#include <QJsonObject>
#include "material.h"



class Record : public QObject
{
    Q_OBJECT
public:
    explicit Record(QObject *parent = nullptr);

public:
    static Record* FromJson(QJsonObject &data);
    static Record* FromMaterial(Material* m, QString shopCode);
    static Record* FromParent(Record* parent, QString shopCode);
    static void SetLocalMac(QString mac){
        localMac = mac;
    };
    // static QString CreateLocalId();

    QJsonObject ToJson();

    QString GetMakeTimeString();
    QString GetValidityTimeString();
    QString GetSaveTypeString();
    QString GetStatusString();

    void Delete();

    bool isExpiring();
    bool isExpired();

public:
    QString CreateTime;
    int DateCount;
    int DateUnit;
    int Deleted;
    int HasPart;
    int HasWarn;
    QString LocalId;
    int MakeAt;
    QString Name;
    int OperationType;
    QString PId;
    int PartCount;
    int PartUnit;
    int RecordId;
    QString Remark;
    int SaveType;
    QString ShopCode;
    QString ShortName;
    int Status;
    int TemplateId;
    QString TypeName;
    int Unit;
    QString UpdateTime;
    int VailAt;
    int WarnCount;
    int WarnUnit;

    bool HadWarnning;

private:
    int computeVailAt(int unit, int count);
    static QString localMac;

signals:
};

#endif // RECORD_H
